package cn.cuiliangpeng.basic.controller;

import cn.cuiliangpeng.basic.domain.dto.RegisterDto;
import cn.cuiliangpeng.basic.service.IVerifyCodeService;
import cn.cuiliangpeng.basic.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService iVerifyCodeService;

    /**
     * 图形验证码
     * @param imageCodeKey
     * @return
     */
    @GetMapping("/image/{imageCodeKey}")
    public AjaxResult verifyCode(@PathVariable(value = "imageCodeKey") String imageCodeKey){
        return iVerifyCodeService.verifyCode(imageCodeKey);
    }


    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody @Valid RegisterDto dto){
        return iVerifyCodeService.sendSmsCode(dto);
    }
}
